CAN Gateway code example  v1.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Typedefs | Enumerations | Functions
canGw Namespace Reference

Namespace for cangw module. More...

Typedefs

typedef void(* RcvCb_t )(const J2534::PASSTHRU_MSG *rxPassThruMsg, unsigned long rxMsgNum)
 Definition of callback function for receive frames.
 

Enumerations

enum  ErrCode_e { CAN_GW_OK, CAN_GW_ERR }
 Definition of CAN Gateway's error codes. More...
 
enum  Channel_e { CHANNEL_1, CHANNEL_2 }
 Definition of CAN Gateway channels' names. More...
 
enum  Baudrate_e { BAUD_125K, BAUD_250K, BAUD_500K, BAUD_1M }
 Definition of CAN Gateway's baud rates. More...
 

Functions

ErrCode_e init (Baudrate_e baudChan1, Baudrate_e baudChan2, const RcvCb_t cbChan1, const RcvCb_t cbChan2)
 Function initializes CAN Gateway device. More...
 
ErrCode_e uninit ()
 Function uninitializes CAN Gateway device. More...
 
ErrCode_e send (Channel_e channel, J2534::PASSTHRU_MSG *txPassThruMsg)
 Function sends PASSTHRU frame via given channel. More...
 
ErrCode_e startPeriodic (Channel_e channel, J2534::PASSTHRU_MSG *txPassThruMsg, unsigned long interval)
 Function starts CAN Gateway's periodic message. More...
 

Detailed Description

Namespace for cangw module.

Enumeration Type Documentation

Definition of CAN Gateway's error codes.

Enumerator
CAN_GW_OK 

No error.

CAN_GW_ERR 

An error occurred.

Definition at line 25 of file cangw.hpp.

Definition of CAN Gateway channels' names.

Enumerator
CHANNEL_1 

Name of CAN Gateway's channel 1.

CHANNEL_2 

Name of CAN Gateway's channel 2.

Definition at line 34 of file cangw.hpp.

Definition of CAN Gateway's baud rates.

Enumerator
BAUD_125K 

Baudrate 125 kbps.

BAUD_250K 

Baudrate 250 kbps.

BAUD_500K 

Baudrate 500 kbps.

BAUD_1M 

Baudrate 1 Mbps.

Definition at line 43 of file cangw.hpp.

Function Documentation

ErrCode_e canGw::init ( Baudrate_e  baudChan1,
Baudrate_e  baudChan2,
const RcvCb_t  cbChan1,
const RcvCb_t  cbChan2 
)

Function initializes CAN Gateway device.

Parameters
[in]baudChan1Baud rate for physical channel 1
[in]baudChan2Baud rate for physical channel 2
[in]cbChan1Callback function for receive on physical channel 1
[in]cbChan2Callback function for receive on physical channel 2
Returns
CAN_GW_OK No error
CAN_GW_ERR An error occurred

Definition at line 124 of file cangw.cpp.

References BAUD_125K, BAUD_1M, BAUD_250K, BAUD_500K, BAUD_VAL_125KBPS, BAUD_VAL_1MBPS, BAUD_VAL_250KBPS, BAUD_VAL_500KBPS, GwParam_s::baudCh1, GwParam_s::baudCh2, CAN_GW_ERR, CAN_GW_OK, canGwInitRcvThread(), canGwOpen(), CHANNEL_1, CHANNEL_2, gwParam, MAX_RX_MSGS, rcvCbCh1, rcvCbCh2, rxPassThruMsgCh1, and rxPassThruMsgCh2.

Referenced by main().

ErrCode_e canGw::uninit ( )

Function uninitializes CAN Gateway device.

Returns
CAN_GW_OK No error
CAN_GW_ERR An error occurred

Definition at line 201 of file cangw.cpp.

References CAN_GW_OK, canGwClose(), canGwUninitRcvThread(), CHANNEL_1, CHANNEL_2, rxPassThruMsgCh1, and rxPassThruMsgCh2.

Referenced by main().

ErrCode_e canGw::send ( Channel_e  channel,
J2534::PASSTHRU_MSG *  txPassThruMsg 
)

Function sends PASSTHRU frame via given channel.

Parameters
[in]channelPhysical channel to be used for sending of a message
[in]txPassThruMsgPointer to a message to be sent
Returns
CAN_GW_OK No error
CAN_GW_ERR An error occurred

Definition at line 228 of file cangw.cpp.

References CAN_GW_ERR, CAN_GW_OK, CHANNEL_1, CHANNEL_2, gwMutex, gwParam, GwParam_s::idCh1, GwParam_s::idCh2, and TX_TIMEOUT.

Referenced by main().

ErrCode_e canGw::startPeriodic ( Channel_e  channel,
J2534::PASSTHRU_MSG *  txPassThruMsg,
unsigned long  interval 
)

Function starts CAN Gateway's periodic message.

Parameters
[in]channelPhysical channel to be used for sending of a periodic message
[in]txPassThruMsgPointer to a message to be sent periodically
[in]intervalInterval for a periodic message in miliseconds
Returns
CAN_GW_OK No error
CAN_GW_ERR An error occurred

Definition at line 263 of file cangw.cpp.

References CAN_GW_ERR, CAN_GW_OK, CHANNEL_1, CHANNEL_2, gwMutex, gwParam, GwParam_s::idCh1, and GwParam_s::idCh2.

Referenced by main().